<?php

namespace App\model;

use Illuminate\Database\Eloquent\Model;

class Power extends Model
{
	/*
	*@content 权限
	*@author  
    */

	public $table = 'power';
    public $timestamps = false;


   /**
    *  权限列表
	*/

	public function powerList($list,$pid=0,$tmp='')
	{
	  static $newList;
	  foreach($list as $k=>$v)
	  {
	     if($v['pid']==$pid)
		 {
             $list[$k]['tmp']=$tmp;
			 $newList[$k]=$list[$k];
			 unset($list[$k]);
			 $this->powerList($list,$v['p_id'],'&nbsp;&nbsp;&nbsp;&nbsp;');
		 
		 }
	  }
	 return $newList;
	
	}

	/**
	 *  重组权限列表数据
	 */
    public function orderPower()
	{
	   $arr=$this->where('pid','!=',0)->get()->toArray();
	   $group=$this->where('pid',0)->get()->toArray();
	   $newArr=array();
	   foreach($group as $v=>$k)
	   {
		 $str=$this->where('pid',$k['p_id'])->get()->toArray();
		 $group[$v]['info']=$str;
		 $newArr[]=$group[$v];
	   }
	   return $newArr;
	}

	

}